package com.sec.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class ConfigBean {

    /**
     * RestTemplate配置到spring中
     * @return
     * AvailabilityFilteringRule 过滤掉故障的服务，对剩下的进行轮询
     * RandomRule  随机
     * RetryRule  会按照轮询获取服务，对故障的服务在指定时间里重试
     */
    //配置负载均衡  IRule
    @LoadBalanced
    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

//    @Bean
//    public IRule myIRule()
//    {
//        return new AvailabilityFilteringRule();
//    }
}
